import { createSlice } from '@reduxjs/toolkit'
import { getKindListData } from '../../api/kind'
const kindSlice = createSlice({
    name: 'kind',
    initialState: {
        kindList: []
    },
    reducers: {
        changeKindList(state, action) {
            // setTimeout(() => {
            state.kindList = action.payload
            // }, 1000)

        }
    }
})

export const { changeKindList } = kindSlice.actions

// 如果需要异步使用状态管理
export function getKindListAction(dispatch) {
    getKindListData().then(res => {
        setTimeout(() => {
            dispatch(changeKindList(res.data.data))
        }, 1000)

    })
}


export default kindSlice.reducer